package cc.wsyw126.java.nowcoder.jd;

import java.util.Scanner;

/**
 * Created by Administrator on 2017/4/7.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.nextLine();
            String[] split = s.split(" ");
            int n = Integer.valueOf(split[0]), k = Integer.valueOf(split[1]);
            int result = 0;
            if (n < k) {
                result = 0;
            }else if (k == 1) {
                result = ((n-1)/3)*2 +1;
            } else {
                result = (n-k)/(k+1) + 1;
            }
            System.out.println(result);
        }
    }
}
